function formatTime(gmtTimeString) {
    const date = new Date(gmtTimeString);

    const year = date.getFullYear();
    const month = date.getMonth() + 1; // 月份从0开始，需要+1
    const day = date.getDate();
    const hours = date.getHours();
    const minutes = date.getMinutes().toString().padStart(2, '0');
    const seconds = date.getSeconds().toString().padStart(2, '0');
    if (!year || !month || !day || !hours || !minutes || !seconds){
        return '---';
    }

    return `${year} ${month}月${day}日 ${hours}:${minutes}:${seconds}`;
}

function isEqual(arr1, arr2) {
    if (arr1.length !== arr2.length) return false;
    for (let i = 0; i < arr1.length; i++) {
        if (arr1[i].toLowerCase() !== arr2[i].toLowerCase()) return false;
    }
    return true;
}


const nextF = (e, func) => {
    if (e.keyCode != 13) {
        return;
    }
    if (func) {
        func();
    }
    
    let fs = document.querySelectorAll("mdui-text-field");
    for (let i = 0; i < fs.length; i++) {

        // 判断是否是当前输入框
        if (fs[i] == e.target) {
            if (i < fs.length - 1) {
                fs[i + 1].focus();
            }

        }
    }
}

export { formatTime,isEqual,nextF };